package com.qf.service.impl;

import com.qf.mapper.ShoppingCartMapper;
import com.qf.pojo.ResultData;
import com.qf.pojo.ShoppingCart;
import com.qf.service.ShoppingCarService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;


@Service
@Transactional//事务锁
public class ShoppingCarServiceImpl implements ShoppingCarService {
    @Resource
    private ShoppingCartMapper shoppingCartMapper;

    @Override
    public ResultData shoppingCarListBycIds( Integer userId, List<Integer> cIds) {

        if (userId != null){
            final List<ShoppingCart> shoppingCartList = shoppingCartMapper.selectCartBycIds(userId, cIds);
            System.out.println(shoppingCartList);
            if (shoppingCartList != null || shoppingCartList.isEmpty()){
                return new ResultData(0,"查询成功",shoppingCartList);
            }else {
                return new ResultData(10000,"查询失败，或数据为空");
            }

        }
        return new ResultData(10000,"传入参数有误 请检查传入的参数");
    }
}
